/**
 * 注意！ 本文件代码用以获取后端数据
 * 为了文件结构而保留，其本身需根据您的需求进行编写
 * 在组件中已经将此部分注释
 * @author xxh 2023-6-3
 */

// 获取文章信息
import httpInstance from '@/utils/http'
export const getAllArticle = (params) => {
  return httpInstance({
    url: '/api/article/getAllArticle',
    method: 'get',
    params: params,
  })
}

// 获取文章详情
export const getArticleDetail = (articleId) => {
  return httpInstance({
    url: `/api/article/getArticleById/${articleId}`,
    method: 'get',
  })
}

// 修改文章
export const updateArticle = (articleId, articleData) => {
  return httpInstance({
    url: `/api/article/updateArticle/${articleId}`, // 使用反引号包裹
    method: 'put',
    data: articleData,
  })
}

// 删除文章
export const deleteArticle = (articleId) => {
  return httpInstance({
    url: `/api/article/deleteArticle/${articleId}`, // 使用反引号包裹
    method: 'put',
  })
}

// 创建动态
export const createArticle = (articleData) => {
  return httpInstance({
    url: '/api/article/createArticle', // 后端创建动态的接口地址
    method: 'post',
    data: articleData, // 动态数据
  })
}

// 获取用户文章
export const getUserArticle = (uid) => {
  return httpInstance({
    url: `/api/article/getUserArticle/${uid}`,
    method: 'get',
  })
}
